< previous page page_79 next page >

Page 79
To use these properties, set the Min and Max properties to values representing the range you want and then access the Value property to find the result. One typical range is from 0 to 100, where the users would enter a number as a percentage.
note.gif The scrollbar can accept whole numbers (integers) anywhere in the range of 32,768 to 32,767. However, the valid values for the Value property depend on the values of the Min and Max properties. Remember this point when you are setting a scrollbar value from code, because a value outside the current range causes an error. square.gif

The Change event of the scrollbar fires when the Value property changes. To test a scrollbar, start a new Standard EXE project. Place a horizontal scrollbar and a text box on the form. Then enter the following code in the Form_Load event and HScroll1_Change events:
Private Sub Form_Load()
    HScroll1.Min = Me.Left
    HScroll1.Max = Me.ScaleWidth
End Sub
Private Sub HScroll1_Change()
    Text1.Left = HScroll1.Value
End Sub
Run the program and set the scrollbar to different values by dragging, clicking, and using the arrow, Home, and End keys. The text box should change positions on the form to match the current setting of the scrollbar.
Controlling the Size of the Value Changes
If you have used a scrollbar in a word processor or other program, you know that clicking the arrow at either end of the bar moves you a short distance, and clicking between an arrow and the position button moves you a larger distance. The scrollbar controls work the same way, and you get to set how much the numbers change with each kind of move. The number entered in a scrollbar is contained in the Value property. This property changes every time you click the scrollbar or drag the position button, as indicated in Figure 4.16.
0079-01.jpg
Figure 4.16
Clicking various parts of the scrollbar changes its value by different amounts.
The amount that the Value property increases or decreases when an arrow is clicked is controlled by the SmallChange property, unless such a change would exceed the bounds of the Min and Max properties. This property gives you very fine control over the numbers being entered. Its default value is 1, which is probably a good number to use for most purposes.
When you click between the arrow and the position button, the Value property can change by a different amount than if you click an arrow. The amount of this change is set by the

 
< previous page page_79 next page >